//
//  DHDetailRadioTableViewCell.m
//  Moment
//
//  Created by dllo on 15/12/25.
//  Copyright © 2015年 片刻. All rights reserved.
//

#import "DHDetailRadioTableViewCell.h"

@implementation DHDetailRadioTableViewCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createViews];
    }
    return self;
}
-(void)createViews{
    _soundImageView = [[UIImageView alloc]init];
    [self.contentView addSubview:_soundImageView];
    _soundCountLabel = [[UILabel alloc]init];
    [self.contentView addSubview:_soundCountLabel];
    _titleImageView = [[UIImageView alloc]init];
    [self.contentView addSubview:_titleImageView];
    _titleLabel = [[UILabel alloc]init];
    [self.contentView addSubview:_titleLabel];
    _PlayImageView = [[UIImageView alloc]init];
    [self.contentView addSubview:_PlayImageView];
    _traingleView = [[UIImageView alloc]init];
    [self.contentView addSubview:_traingleView];
    _boolNewView = [[UIImageView alloc]init];
    [self.contentView addSubview:_boolNewView];
    
}
-(void)setRadio:(DHSubRadio *)radio{
    if (_radio != radio) {
        _radio = radio;
    }
 [_titleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
     make.top.equalTo(@(SCREEN_WIDTH * 0.02));
     make.left.equalTo(@(SCREEN_WIDTH * 0.04));
     make.bottom.equalTo(@(-SCREEN_WIDTH * 0.02));
     make.width.equalTo(_titleImageView.mas_height);
 }];

    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_titleImageView.mas_right).offset(5);
        make.top.equalTo(@(SCREEN_WIDTH * 0.02));
        make.height.equalTo(_titleImageView.mas_height).multipliedBy(0.33);
        make.width.equalTo(@(SCREEN_WIDTH * 0.4));
        
    }];

    [_soundImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_titleImageView.mas_right).offset(5);
        make.bottom.equalTo(@(-SCREEN_WIDTH * 0.02));
        make.width.and.height.equalTo(@(15*WIDTH));
    }];

    [_soundCountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_soundImageView.mas_right).offset(3);
        make.top.equalTo(_soundImageView.mas_top);
        make.height.equalTo(_soundImageView.mas_height);
        make.width.equalTo(_titleImageView.mas_width);
    }];

    [_PlayImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@(-SCREEN_WIDTH * 0.04));
        make.top.equalTo(@(SCREEN_WIDTH * 0.05));
        make.bottom.equalTo(@(-SCREEN_WIDTH * 0.05));
        make.width.equalTo(_PlayImageView.mas_height);
    }];
    [_traingleView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@(-SCREEN_WIDTH * 0.047));
        make.top.equalTo(@(SCREEN_WIDTH * 0.06));
        make.bottom.equalTo(@(-SCREEN_WIDTH * 0.06));
        make.width.equalTo(_traingleView.mas_height);
    }];
    [_boolNewView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_titleImageView.mas_top);
        make.left.equalTo(_titleImageView.mas_left);
        make.width.and.height.equalTo(_titleImageView.mas_height).multipliedBy(0.5);
    }];
    _traingleView.image = [UIImage imageNamed:@"iconfont-bofang-2"];
    _PlayImageView.image = [UIImage imageNamed:@"yuan.png"];
    NSURL *url = [NSURL URLWithString:_radio.coverimg];
    [_titleImageView sd_setImageWithURL:url placeholderImage:PLACEHOLDER_IMAGE];
    _titleLabel.text = _radio.title;
    _titleLabel.font = [UIFont systemFontOfSize:13];
    _soundImageView.image = [UIImage imageNamed:@"iconfont-shengyin"];
    _soundCountLabel.text = _radio.musicVisit;
    _soundCountLabel.font = [UIFont systemFontOfSize:8];
    _soundCountLabel.textColor = [UIColor grayColor];
    if (_radio.isnew) {
        _boolNewView.hidden = NO;
        _boolNewView.image = [UIImage imageNamed:@"new"];
    }else{
    _boolNewView.hidden = YES;
    }
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
